import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { TextRenderer } from "../engine/TextRenderer";
import { Transform } from "../engine/Transform";
import { number } from "../engine/validators/number";
import { dateStorageInUI } from "./dateStorageInUI";
import { Display } from "./Display";
import { ItemSpeed } from "./ItemSpeed";
import { OrderButtonClick } from "./OrderButtonClick";



export class UIGetFromSchoolScene extends Behaviour {

     Order_text:string;
     Order_text_detail:string;
     Clicked_Flag=0;

    onStart() {
       

        this.gameObject.onClick = () => {
         this.Clicked_Flag++;
             console.log(this.gameObject.id);
             if(this.Clicked_Flag%2!=0){
               this.Order_text=getGameObjectById('dateStorage').getBehaviour(dateStorageInUI).currentOrder;
               this.Order_text_detail=getGameObjectById('UI_dialog_requirement_detail').getBehaviour(TextRenderer).text;

             getGameObjectById('UI_orderBig').getBehaviour(Display).IsActive=true;
             getGameObjectById('Text_order').getBehaviour(Display).IsActive=true;
             getGameObjectById('Text_order').getBehaviour(TextRenderer).text=this.Order_text;

             if(getGameObjectById('UI_dialog_button_getIt').getBehaviour(OrderButtonClick).getit_clickFlag==1){
                getGameObjectById('Text_getit').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_order_ detail').getBehaviour(Display).IsActive=false;
                getGameObjectById('Text_getit_2').getBehaviour(Display).IsActive=false;
                getGameObjectById('Text_what').getBehaviour(Display).IsActive=false;
             }

             if(getGameObjectById('UI_dialog_button_getIt').getBehaviour(OrderButtonClick).getit_clickFlag==1&&
             getGameObjectById('UI_dialog_button_what').getBehaviour(OrderButtonClick).what_clickFlag==1){
                //getGameObjectById('UI_dialog_button_what').getBehaviour(OrderButtonClick).what_clickFlag=0;
                getGameObjectById('Text_getit').getBehaviour(Display).IsActive=false;
                getGameObjectById('Text_order_ detail').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_getit_2').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_what').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_order_ detail').getBehaviour(TextRenderer).text=this.Order_text_detail; 
             }
             }

             if(this.Clicked_Flag%2==0){
               getGameObjectById('UI_orderBig').getBehaviour(Display).IsActive=false;
               getGameObjectById('Text_order').getBehaviour(Display).IsActive=false;
               getGameObjectById('Text_getit').getBehaviour(Display).IsActive=false;
               getGameObjectById('Text_what').getBehaviour(Display).IsActive=false;
               getGameObjectById('Text_getit_2').getBehaviour(Display).IsActive=false;
               getGameObjectById('Text_order_ detail').getBehaviour(Display).IsActive=false;
             }
             
             
            /* if(getGameObjectById('UI_dialog_button_what').getBehaviour(OrderButtonClick).getit_clickFlag==1){
                getGameObjectById('Text_Order_detail').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_what').getBehaviour(Display).IsActive=true;
                getGameObjectById('Text_Order_detail').getBehaviour(TextRenderer).text=getGameObjectById('UI_dialog_requirement').getBehaviour(TextRenderer).text;
             }*/
            
             
             console.log(this.Order_text);
             
        };
    }

    onTick(duringTime: number) {

    }
}
